<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     base_default
 * @copyright   Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
/* @var $this Mage_Catalog_Block_Product_Compare_Sidebar */
?>
<?php 
    /* Check Homepage */
    $page = Mage::app()->getFrontController()->getRequest()->getRouteName();
    $homePage = false;
    if($page =='cms'){
        $cmsSingletonIdentifier = Mage::getSingleton('cms/page')->getIdentifier();
        $homeIdentifier = Mage::app()->getStore()->getConfig('web/default/cms_home_page');
        if($cmsSingletonIdentifier === $homeIdentifier){
            $homePage = true;
        }
    }
    /* End Check Homepage */
?>
<?php if($homePage==false ||  ($homePage == true && Mage::helper('themeframework/settings')->getHomePosition_Compare()) ):?>
    <?php
        $_helper = $this->helper('catalog/product_compare');
        $_items = $_helper->getItemCount() > 0 ? $_helper->getItemCollection() : null;
        $setting = Mage::helper('themeframework/settings');
        $width	=	$setting->getImageSidebar_Width(100);
        $height	=	$setting->getImageSidebar_Height(100);
    ?>
    <div class="em-line-01 block block-list block-compare ">
        <div class="em-block-title block-title">
            <strong><span><?php echo $this->__('Compare Products') ?><?php echo ' ('.$_helper->getItemCount().')' ?></span></strong>
        </div>
        <div class="block-content">
            <?php if($_helper->getItemCount() > 0): ?>
                <ol id="compare-items">
                    <?php foreach($_items as $_index => $_item): ?>
                        <li class="item">
                            <input type="hidden" class="compare-item-id" value="<?php echo $_item->getId() ?>" />
                            <?php $_product = Mage::getModel('catalog/product')->load($_item->getId()); ?>
                            <a href="<?php echo $_helper->getRemoveUrl($_item) ?>" title="<?php echo $this->__('Remove This Item') ?>" class="btn-remove" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove this item from the compare products?') ?>');"><?php echo $this->__('Remove This Item') ?></a>
                            <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($width,$height) ?>" width="<?php echo $width;?>" height="<?php echo $height;?>" alt="<?php echo $this->stripTags($_product->getName(), null, true) ?>" /></a>
                            <div class="product-shop">
                                <div class="f-fix">
                                    <h3 class="product-name">
                                        <a href="<?php echo $_product->getProductUrl() ?>"
                                           title="<?php echo $this->stripTags($_product->getName(), null, true) ?>">
                                            <?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName() , 'name') ?>
                                        </a>
                                    </h3>
                                    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                                    <?php echo $this->getPriceHtml($_product, true, '-widget-new-list') ?>
                                </div>
                            </div>
                        </li>
                    <?php endforeach; ?>
                </ol>
                <script type="text/javascript">decorateList('compare-items')</script>
                <div class="actions">
                    <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Compare')) ?>" class="button" onclick="popWin('<?php echo $_helper->getListUrl() ?>','compare','top:0,left:0,width=820,height=600,resizable=yes,scrollbars=yes')"><span><span><?php echo $this->__('Compare') ?></span></span></button>
                    <a class="button-link" href="<?php echo $_helper->getClearListUrl() ?>" onclick="return confirm('<?php echo $this->__('Are you sure you would like to remove all products from your comparison?') ?>');"><span><span><?php echo $this->__('Clear All') ?></span></span></a>
                </div>
            <?php else: ?>
                <p class="empty"><?php echo $this->__('You have no items to compare.') ?></p>
            <?php endif; ?>
        </div>
    </div>    
<?php endif;?>